package org.example.controller;

import com.qidian.common.pojo.MESResult;
import com.qidian.mes.pojo.Defect;
import com.qidian.mes.pojo.Menu;
import org.example.service.DefectService;
import org.example.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 严伟伦
 * @Company 无
 * @Description
 * @Date: 2024/10/16 18:49
 */
@RestController
@RequestMapping("/defect")
@CrossOrigin
public class DefectController {
    @Autowired
    private DefectService defectService;
    @GetMapping("/list")
    public MESResult list(Defect defect, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){
        return defectService.queryByPage(defect,page,limit);
    }


    @PostMapping("/add")
    public MESResult addDefect(@RequestBody Defect defect){

        return defectService.addDefect(defect);
    }


    @PutMapping("/update")
    public MESResult updateDefect(@RequestBody Defect defect){

        return defectService.updateDefect(defect);
    }

    @GetMapping("/selectDefectById")
    public MESResult selectDefectById(@RequestParam("defectId") int defectId){

        return defectService.selectDefectById(defectId);
    }


    @PutMapping("/delete")
    public MESResult deleteDefectById(@RequestParam("defectId") int defectId){
        return defectService.deleteDefectById(defectId);
    }

    @PutMapping("/deletes")
    public MESResult deletes(@RequestBody int[] defectIds){
        return defectService.deletes(defectIds);
    }

}
